package com.zysd.collection.scheduler.entity;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * 任务模板实体类
 *
 * @author liuht
 * @date 2017/10/13 9:32
 */
public class SchedulerTaskModel implements Serializable {
    private Long id;

    @NotNull(message = "模板名称不能为空")
    private String taskName;

    private String taskRange;

    @NotNull(message = "任务对象类型不能为空")
    private String taskType;

    private String afns;

    @NotNull(message = "任务执行类型不能为空")
    private String executeType;

    /**
     * 召测时间
     */
    private Integer collectTime;

    private String cronExpression;

    private String reportingCycle;

    private String reportingCycleUnit;

    private Integer transCycle;

    private String termType;

    private String measureRetryEnable;

    private Integer measureRetryTimes;

    private Integer measureRetryInterval;

    private String measureRetryUnit;

    private Integer measureRetryDelay;

    private String isEnable;

    private Long orgId;

    /**
     * 模板对应任务状态
     */
    private Integer taskStatus;

    private static final long serialVersionUID = 1L;

    public SchedulerTaskModel(Long id, String taskName, String taskRange, String taskType, String afns, String executeType, Integer collectTime, String cronExpression, String reportingCycle, String reportingCycleUnit, Integer transCycle, String termType, String measureRetryEnable, Integer measureRetryTimes, Integer measureRetryInterval, String measureRetryUnit, Integer measureRetryDelay, String isEnable, Long orgId) {
        this.id = id;
        this.taskName = taskName;
        this.taskRange = taskRange;
        this.taskType = taskType;
        this.afns = afns;
        this.executeType = executeType;
        this.collectTime = collectTime;
        this.cronExpression = cronExpression;
        this.reportingCycle = reportingCycle;
        this.reportingCycleUnit = reportingCycleUnit;
        this.transCycle = transCycle;
        this.termType = termType;
        this.measureRetryEnable = measureRetryEnable;
        this.measureRetryTimes = measureRetryTimes;
        this.measureRetryInterval = measureRetryInterval;
        this.measureRetryUnit = measureRetryUnit;
        this.measureRetryDelay = measureRetryDelay;
        this.isEnable = isEnable;
        this.orgId = orgId;
    }

    public SchedulerTaskModel() {
        super();
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTaskName() {
        return taskName;
    }

    public void setTaskName(String taskName) {
        this.taskName = taskName == null ? null : taskName.trim();
    }

    public String getTaskRange() {
        return taskRange;
    }

    public void setTaskRange(String taskRange) {
        this.taskRange = taskRange == null ? null : taskRange.trim();
    }

    public String getTaskType() {
        return taskType;
    }

    public void setTaskType(String taskType) {
        this.taskType = taskType == null ? null : taskType.trim();
    }

    public String getAfns() {
        return afns;
    }

    public void setAfns(String afns) {
        this.afns = afns == null ? null : afns.trim();
    }

    public String getExecuteType() {
        return executeType;
    }

    public void setExecuteType(String executeType) {
        this.executeType = executeType == null ? null : executeType.trim();
    }

    public Integer getCollectTime() {
        return collectTime;
    }

    public void setCollectTime(Integer collectTime) {
        this.collectTime = collectTime;
    }

    public String getCronExpression() {
        return cronExpression;
    }

    public void setCronExpression(String cronExpression) {
        this.cronExpression = cronExpression == null ? null : cronExpression.trim();
    }

    public String getReportingCycle() {
        return reportingCycle;
    }

    public void setReportingCycle(String reportingCycle) {
        this.reportingCycle = reportingCycle == null ? null : reportingCycle.trim();
    }

    public String getReportingCycleUnit() {
        return reportingCycleUnit;
    }

    public void setReportingCycleUnit(String reportingCycleUnit) {
        this.reportingCycleUnit = reportingCycleUnit == null ? null : reportingCycleUnit.trim();
    }

    public Integer getTransCycle() {
        return transCycle;
    }

    public void setTransCycle(Integer transCycle) {
        this.transCycle = transCycle;
    }

    public String getTermType() {
        return termType;
    }

    public void setTermType(String termType) {
        this.termType = termType == null ? null : termType.trim();
    }

    public String getMeasureRetryEnable() {
        return measureRetryEnable;
    }

    public void setMeasureRetryEnable(String measureRetryEnable) {
        this.measureRetryEnable = measureRetryEnable == null ? null : measureRetryEnable.trim();
    }

    public Integer getMeasureRetryTimes() {
        return measureRetryTimes;
    }

    public void setMeasureRetryTimes(Integer measureRetryTimes) {
        this.measureRetryTimes = measureRetryTimes;
    }

    public Integer getMeasureRetryInterval() {
        return measureRetryInterval;
    }

    public void setMeasureRetryInterval(Integer measureRetryInterval) {
        this.measureRetryInterval = measureRetryInterval;
    }

    public String getMeasureRetryUnit() {
        return measureRetryUnit;
    }

    public void setMeasureRetryUnit(String measureRetryUnit) {
        this.measureRetryUnit = measureRetryUnit == null ? null : measureRetryUnit.trim();
    }

    public Integer getMeasureRetryDelay() {
        return measureRetryDelay;
    }

    public void setMeasureRetryDelay(Integer measureRetryDelay) {
        this.measureRetryDelay = measureRetryDelay;
    }

    public String getIsEnable() {
        return isEnable;
    }

    public void setIsEnable(String isEnable) {
        this.isEnable = isEnable == null ? null : isEnable.trim();
    }

    public Long getOrgId() {
        return orgId;
    }

    public void setOrgId(Long orgId) {
        this.orgId = orgId;
    }

    public Integer getTaskStatus() {
        return taskStatus;
    }

    public void setTaskStatus(Integer taskStatus) {
        this.taskStatus = taskStatus;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }

        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        SchedulerTaskModel that = (SchedulerTaskModel) o;

        return new EqualsBuilder()
                .append(id, that.id)
                .append(taskName, that.taskName)
                .append(taskRange, that.taskRange)
                .append(taskType, that.taskType)
                .append(afns, that.afns)
                .append(executeType, that.executeType)
                .append(collectTime, that.collectTime)
                .append(cronExpression, that.cronExpression)
                .append(reportingCycle, that.reportingCycle)
                .append(reportingCycleUnit, that.reportingCycleUnit)
                .append(transCycle, that.transCycle)
                .append(termType, that.termType)
                .append(measureRetryEnable, that.measureRetryEnable)
                .append(measureRetryTimes, that.measureRetryTimes)
                .append(measureRetryInterval, that.measureRetryInterval)
                .append(measureRetryUnit, that.measureRetryUnit)
                .append(measureRetryDelay, that.measureRetryDelay)
                .append(isEnable, that.isEnable)
                .append(orgId, that.orgId)
                .append(taskStatus, that.taskStatus)
                .isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37)
                .append(id)
                .append(taskName)
                .append(taskRange)
                .append(taskType)
                .append(afns)
                .append(executeType)
                .append(collectTime)
                .append(cronExpression)
                .append(reportingCycle)
                .append(reportingCycleUnit)
                .append(transCycle)
                .append(termType)
                .append(measureRetryEnable)
                .append(measureRetryTimes)
                .append(measureRetryInterval)
                .append(measureRetryUnit)
                .append(measureRetryDelay)
                .append(isEnable)
                .append(orgId)
                .append(taskStatus)
                .toHashCode();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("id", id)
                .append("taskName", taskName)
                .append("taskRange", taskRange)
                .append("taskType", taskType)
                .append("afns", afns)
                .append("executeType", executeType)
                .append("collectTime", collectTime)
                .append("cronExpression", cronExpression)
                .append("reportingCycle", reportingCycle)
                .append("reportingCycleUnit", reportingCycleUnit)
                .append("transCycle", transCycle)
                .append("termType", termType)
                .append("measureRetryEnable", measureRetryEnable)
                .append("measureRetryTimes", measureRetryTimes)
                .append("measureRetryInterval", measureRetryInterval)
                .append("measureRetryUnit", measureRetryUnit)
                .append("measureRetryDelay", measureRetryDelay)
                .append("isEnable", isEnable)
                .append("orgId", orgId)
                .append("taskStatus", taskStatus)
                .toString();
    }
}
